package com.davidtorma.site;

import java.io.Serializable;


public class GalleryItem implements Serializable{
	private String root = Constants.ICON_PATH;
	private String mainCategory;
	private String subCategory;
	private String imageName;

	public GalleryItem() {
		
	}
	public GalleryItem(String mainCategory, String subCategory, String imageName) {
		super();
		this.mainCategory = mainCategory;
		this.subCategory = subCategory;
		this.imageName = imageName;
	}
	
	public GalleryItem(String mainCategory, String imageName) {
		this(mainCategory, null, imageName);
	}
	
	public String getMainCategory() {
		return mainCategory;
	}

	public void setMainCategory(String mainCategory) {
		this.mainCategory = mainCategory;
	}

	public String getSubCategory() {
		return subCategory;
	}

	public void setSubCategory(String subCategory) {
		this.subCategory = subCategory;
	}

	public String getImageName() {
		return imageName;
	}

	public void setImageName(String imageName) {
		this.imageName = imageName;
	}
	
	public String getRoot() {
		return root;
	}
	
	public String toHtml() {
		StringBuilder html = new StringBuilder();
		html.append("<div class='galeryimg ");
		html.append(mainCategory +" " + (!StringHelper.isBlank(subCategory) ? subCategory : "") + "'>");
		html.append("<img src='" + getPath() + "' />");
		html.append("</div>");
		return html.toString();
	}

	public String getPath() {
		return root + "/" + mainCategory + "/" + (StringHelper.isBlank(subCategory) ? "" : subCategory  + "/") + imageName;
	}

	@Override
	public String toString() {
		return getPath();
	}
}
